% Figure 6
% Average premiums for secondary market sales of credit card
% receivables portfolios
% This figure plots the annual estimates of the average premiums for
% secondary market sales of credit card receivables portfolios.

%Note: Data used in Figure 6 collected manually from the sources described
%in the paper.

clear; clc;

Year = [1986; 1987; 1988; 1989; 1990; 1998; 1999; 2000; 2001; 2002; 2003; 2004;	2005; 2006;	2007; 2008;	2009; 2010;	2011; 2012; 2013; 2014;	2015; 2016];
Premium = [13.04; 15.64; 25.00; 19.25; 25.06; 13.10; 16.42; 18.50; 18.10; 17.40; 18.60; 19.60; 20.40; 19.80; 21.40; 16.50; 13.30; 15.00; 14.40; 16.07; 16.25; 17.20; 17.95; 15.20];
Dates = repmat(datetime(2020,1,1),length(Year),1);
for i=1:length(Year)
   Dates(i,1) = datetime(Year(i),1,1); 
end


plotData = timetable(Premium,'RowTimes',Dates);
plotData = retime(plotData,datetime("1-Jan-1986"):caldays(1):datetime("1-Jan-2017"),'previous');
plotData.Properties.DimensionNames(1) = "Date";
tmpRng = timerange(datetime("1-Jan-1991"),datetime("31-Dec-1997"));
plotData.Premium(tmpRng) = NaN;

plotData_1 = plotData(timerange(datetime("1-Jan-1986"),datetime("1-Jan-1992")),:);
plotData_2 = plotData(timerange(datetime("1-Jan-1998"),datetime("1-Jan-2017")),:);

fig1 = figure('NumberTitle', 'Off', 'Name', 'Figure 1');

letterWidth_inches = 8.5;
letterHeight_inches = 11.0;
letterWidth_cm = 21.59;
letterHeight_cm = 27.94;
letterWidth_pixel = 2250; 
letterHeight_pixel = 3300;

paperWidth  = letterWidth_cm;
paperHeight = letterHeight_cm;
leftMargin = 1;
bottomMargin  = 1; 
figOrientation = 'portrait';
figWidth = 18; 
figHeight = 12; 

set(fig1,'Units','centimeters');
set(fig1,'Position',[0 0 figWidth figHeight]);
movegui(fig1,'center')

set(fig1,'PaperUnits', 'centimeters');
set(fig1,'PaperSize', [paperWidth paperHeight]);
set(fig1,'PaperPosition',[leftMargin bottomMargin figWidth figHeight]);
set(fig1,'PaperSize', [figWidth figHeight]);
set(fig1,'PaperPosition',[0 0 figWidth figHeight]);
set(fig1,'PaperOrientation',figOrientation);
set(fig1,'InvertHardcopy','on');

plot_1 = stairs(datenum(plotData_1.Date),plotData_1.Premium);
set(plot_1, 'LineStyle', '-', 'Color', 'b' , 'LineWidth', 1.00);
hold on
plot_2 = stairs(datenum(plotData_2.Date),plotData_2.Premium);
set(plot_2, 'LineStyle', '-', 'Color', 'b' , 'LineWidth', 1.00);
ax = gca;
ax.PlotBoxAspectRatio = [1,0.35,0.35];
ylim([0 35])

minX = min(datenum(plotData.Date));
maxX = max(datenum(plotData.Date));
xlim([minX-0.25 maxX+0.025])
dateaxis
set(gca,'XTick',datenum([...
    'Jan-1-1990'; ...
    'Jan-1-1995'; ...
    'Jan-1-2000'; ...
    'Jan-1-2005'; ...
    'Jan-1-2010'; ...
    'Jan-1-2015']));
set(gca,'XTickLabel',[...
    '1990';...
    '1995';...
    '2000';...
    '2005';...
    '2010';...
    '2015'])
set(gca,'YTick',[0;5;10;15;20;25;30;35]);
set(gca,'YTickLabel',["0";"5";"10";"15";"20";"25";"30";"35"]);
ylabel('Percent')
grid 'on';
box 'on';
set(gcf, 'Color', [1,1,1]);



